package com.augmented.jellybean;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class CategoryListActivity extends Activity {

	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.augmented_jellybean_categorylist);
		
		ListView lv = (ListView) findViewById(R.id.categorylistview);
		String[] categories = getResources().getStringArray(R.array.categorylist);
		
		lv.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, R.id.label, categories));
		
		lv.setOnItemClickListener(new OnItemClickListener(){

			@Override
			public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
				String category = ((TextView)v).getText().toString();
				
				Log.e("onItemClick", category + " clicked");
				Intent nextScreen = new Intent(getApplicationContext(), AugmentedJellybeanMapScreenActivity.class);
				nextScreen.putExtra("search_input", category);
				startActivity(nextScreen);
			}
			
		});
	}
}
